<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>55社区</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/theme/default/images/favicon.png">
    <jsp:include page="common.jsp"></jsp:include>

</head>
<body>
<header data-am-widget="header" class="am-header am-header-default sq-head ">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.back()" class="">
            <i class="am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="" class="">管理收货地址</a>
    </h1>
    <div class="am-header-right am-header-nav">
        <a href="${ctx}/address.jsp" class="">
            <i class="am-icon-plus"></i>
        </a>
    </div>
</header>
<div style="height: 49px;"></div>
<ul class="address-list">
    <c:forEach var="a" items="${deliveryList}">
        <li class="">
            <p>收货人：${a.delivery_name}&nbsp;&nbsp;${a.delivery_phone}</p>
            <p class="order-add1">收货地址：${a.delivery_address}</p>
            <hr/>
            <div class="address-cz">
                <label class="am-radio am-warning">
                    <input type="radio" name="radio3" class="check" value="" data-am-ucheck checked> 设为默认
                </label>
                <a href="${ctx}/delivery/update.do?id=${a.delivery_id}"><img src="${ctx}/static/images/bj.png"
                                                                             width="18"/>&nbsp;编辑</a>
                <a class="delete">删除</a>
                <div style="display: none">${a.delivery_id}</div>
            </div>
        </li>
    </c:forEach>

</ul>
<script>
    $(".delete").click(function () {
        var id = $(this).siblings("div").text().trim();
        $.post("${ctx}/delivery/delete.do", {"id": id}, function () {

        }, "json")
        setTimeout(function () {
            window.location.reload()
        }, 1000)
    })
    $(".check").click(function () {
        $(".am-radio").each(function () {
            if ($(this).find(".check").prop("checked")) {
                $(this).parent().parent().siblings().removeClass("curr");
                $(this).parent().parent().addClass("curr");
            }
        })
        var tid = $(this).parent().siblings("div").text().trim();
        $.post("${ctx}/trolley/tid.do", {"tid": tid}, function () {

        }, "json")
    })
    $(function () {
        $(".am-radio").each(function () {
            $(this).parent().parent().siblings().removeClass("curr");
            $(this).parent().parent().eq(0).addClass("curr");

        })
    })
</script>
</body>
</html>
